import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)


const store = new Vuex.Store({
    state: {
		hasLogin: false,
		userInfo: {},
		jumpUrl: '', // 分享跳转路径
		orderId: '', // 分享方案orderId
	},
    mutations: {
		login(state, userInfo) {
            state.userInfo = userInfo;
            state.hasLogin = true;
            uni.setStorage({
                key: 'userInfo',
                data: userInfo,
            });
        },
        logout(state) {
            state.userInfo = {};
            state.hasLogin = false;
            uni.removeStorageSync('userInfo')
			uni.removeStorageSync('token')
			uni.removeStorageSync('unReadCount')
        },
		getUser(state, userInfo) {
			state.userInfo = userInfo;
			uni.setStorage({
			    key: 'userInfo',
			    data: userInfo,
			});
		},
		saveJumpUrl(state, url) {
			state.jumpUrl = url;
		},
		saveWearPlanOrderId(state, orderId) {
			uni.setStorageSync('wearPlanOrderid', orderId)
			state.orderId = orderId;
		}
	},
    actions: {
		
		
	}
})
export default store